import wx

class CarPanel(wx.Panel):
    def __init__(self, parent):
        super(CarPanel, self).__init__(parent)
        self.Bind(wx.EVT_PAINT, self.OnPaint)

    def OnPaint(self, event):
        dc = wx.PaintDC(self)
        dc.SetBrush(wx.Brush(wx.Colour(255, 0, 0)))  # 设置红色画刷
        dc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1))     # 设置黑色画笔

        # 绘制车身
        dc.DrawRectangle(50, 100, 200, 50)  # 车身主体
        dc.DrawRectangle(100, 50, 100, 50)  # 车顶

        # 绘制车轮
        dc.SetBrush(wx.Brush(wx.Colour(0, 0, 0)))  # 设置黑色画刷
        dc.DrawCircle(80, 150, 20)  # 左车轮
        dc.DrawCircle(220, 150, 20)  # 右车轮

        # 绘制车窗
        dc.SetBrush(wx.Brush(wx.Colour(173, 216, 230)))  # 设置浅蓝色画刷
        dc.DrawRectangle(110, 60, 30, 30)  # 左车窗
        dc.DrawRectangle(160, 60, 30, 30)  # 右车窗

        # 绘制车灯
        dc.SetBrush(wx.Brush(wx.Colour(255, 255, 0)))  # 设置黄色画刷
        dc.DrawCircle(260, 120, 10)  # 右车灯

class CarFrame(wx.Frame):
    def __init__(self):
        super(CarFrame, self).__init__(None, title="小汽车图案", size=(350, 250))
        self.panel = CarPanel(self)
        self.Centre()
        self.Show()

if __name__ == "__main__":
    app = wx.App(False)
    frame = CarFrame()
    app.MainLoop()
